package com.beanbean.mvvmtest;

import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.beanbean.mvvmtest.bean.UserInfo;
import com.beanbean.mvvmtest.databinding.ActivityMainBinding;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
        UserInfo userInfo = new UserInfo("小牛", 20);
        binding.setUser(userInfo);
        binding.setHandleClick(new HandleOnclick());
    }

    public class HandleOnclick {
        public void onClickName(View view) {
            Intent intent = new Intent(MainActivity.this, ListActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
        }
    }

}
